/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.interaction3d.assembly.convert.collada;

/**
 *
 * @author micha
 */
final class Input
{
    public final int offset;
    public final String semantic;
    public final String source;
    public final int set;

    public Input(int offset, String semantic, String source, int set)
    {
        if(semantic == null || source == null)
        {
            throw new NullPointerException();
        }
        
        this.offset = offset;
        this.semantic = semantic;
        this.source = source;
        this.set = set;
    }

    public boolean hasExternalSource()
    {
        return source.charAt(0) != '#';
    }

    public static int groups(Input... inputs)
    {
        int groups = 0;

        for(Input input : inputs)
        {
            groups = Math.max(groups, input.offset+1);
        }
        return groups;
    }

    public static Input select(String semantic, int set, Input... inputs)
    {
        for(Input input : inputs)
        {
            if(input.set == set && input.semantic.equals(semantic))
            {
                return input;
            }
        }
        return null;        
    }
}